namespace Crux.Core.LangChain.Abstractions.ChatCompletion;
/// <summary>
/// 
/// </summary>
public readonly struct Role : IEquatable<Role>
{
    /// <summary>
    ///
    /// </summary>
    public static Role System { get; } = new("system");

    /// <summary>
    ///
    /// </summary>
    public static Role Assistant { get; } = new("assistant");

    /// <summary>
    /// 
    /// </summary>
    public static Role User { get; } = new("user");

    /// <summary>
    /// 
    /// </summary>
    public static Role Tool { get; } = new("tool");

    /// <summary>
    /// 
    /// </summary>
    /// <param name="label"></param>
    /// <exception cref="ArgumentNullException"></exception>
    public Role(string label)
    {
        if (string.IsNullOrEmpty(label)) throw new ArgumentNullException(nameof(label));

        this.Label = label!;
    }
    /// <summary>
    /// 
    /// </summary>
    public string Label { get; }

    /// <inheritdoc/>
    public override bool Equals(object? obj)
        => obj is Role otherRole && this.Label == otherRole.Label;

    /// <summary>
    /// 
    /// </summary>
    /// <param name="obj"></param>
    /// <returns></returns>
    public bool Equals(Role obj)
        => obj is Role otherRole && this.Label == otherRole.Label;
    /// <summary>
    /// 
    /// </summary>
    /// <param name="left"></param>
    /// <param name="right"></param>
    /// <returns></returns>
    public static bool operator ==(Role left, Role right)
        => left.Equals(right);
    /// <summary>
    /// 
    /// </summary>
    /// <param name="left"></param>
    /// <param name="right"></param>
    /// <returns></returns>
    public static bool operator !=(Role left, Role right)
        => !(left == right);
    /// <summary>
    /// 
    /// </summary>
    /// <returns></returns>
    /// <inheritdoc/>
    public override int GetHashCode()
        => StringComparer.OrdinalIgnoreCase.GetHashCode(this.Label);

    /// <inheritdoc/>
    public override string ToString() => this.Label;
}
